<template>
  <div>
    <div v-if="this.typeId!=='view'">
      <router-link :to="{ name: 'shoppingEditPage',query:{goodsNum:this.typeId}}">
        <el-button size="small">编辑</el-button>
      </router-link>
    </div>
    <div v-if="this.typeId==='view'">
      <router-link :to="{ name: 'shoppingEditPage',query:{goodsNum:'view'}}">
        <el-button size="small" >返回</el-button>
      </router-link>
    </div>
    <div class="whiteBac mt10 p20 fs14">
      <div class="">
        <div class="a-left-w">商品名称：</div>
        <div class="fl">{{baseInfo.name}}</div>
        <div class="clear"></div>
      </div>
      <div class="mt10">
        <div class="a-left-w">商品积分：</div>
        <div class="fl">{{baseInfo.integral}}</div>
        <div class="clear"></div>
      </div>
      <div class="mt10">
        <div class="a-left-w">商品类型：</div>
        <div class="fl">{{baseInfo.type==='0'?"实物":"虚拟"}}</div>
        <div class="clear"></div>
      </div>
      <div class="mt15">
        <div class="a-left-w">PC&APP列表图片：</div>
        <div class="fl"><img :src="baseInfo.img_url" alt="" width="330" ></div>
        <div class="clear"></div>
      </div>
      <div class="mt15">
        <div class="a-left-w">APP详情图片：</div>
        <div class="fl"><img :src="baseInfo.img_url_detail_app" alt="" width="330"></div>
        <div class="clear"></div>
      </div>
      <div class="mt15">
        <div class="a-left-w">PC详情&PC订单&APP订单图片：</div>
        <div class="fl"><img :src="baseInfo.img_url_detail_pc" alt="" width="200"></div>
        <div class="clear"></div>
      </div>
      <div class="mt10">
        <div class="a-left-w">商品详情：</div>
        <div class="fl lh20 break" v-html="baseInfo.simple_desc"></div>
        <div class="clear"></div>
      </div>
    </div>
  </div>
</template>

<script>
  import service from '@/service/index'
  import { getCookie } from '@/base/utils'
  export default {
    data(){
      return{
        baseInfo:{},
        typeId:''
      }
    },
    mounted() {
      this.typeId = this.$route.query.goodsSerialNumber;
      this.initMethod();
    },
    methods:{
      initMethod(){
        if(this.typeId==='view'){
          this.baseInfo = getCookie('viewData')||{};
          //console.log(JSON.stringify(this.baseInfo,'---------------'));
        }else{
          this.getGoodsNumDetails();
          //console.log(JSON.stringify('================'));
        }
      },
      getGoodsNumDetails(){
        service.haiBeiServerQueryGoodsById({id:this.typeId}).then(res => {
          if (res.success) {
            this.baseInfo = res.result;
          }else{
            this.$message({type:'error', message:res.msg});
            return;
          }
        });
      },
    }
  }
</script>

<style scoped>

</style>
